<?php
require_once("database.php");
class xl_phuong_thuc_thanh_toan extends database
{
	function danh_sach($vi_tri, $so_luong)
	{
		$vi_tri = intval($vi_tri);
		$so_luong = intval($so_luong);
		$sql = "select * from phuong_thuc_thanh_toan limit $vi_tri, $so_luong";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	function danh_sach_all()
	{
		$sql = "select * from phuong_thuc_thanh_toan ORDER BY  ma ASC ";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	function so_luong()
	{
		$sql = "select count(*) from phuong_thuc_thanh_toan";
		$this->setQuery($sql);
		return $this->loadResult();
	}
	function xem($ma)
	{
		$ma = intval($ma);

		$sql = "select * from phuong_thuc_thanh_toan where ma = '$ma'";
		$this->setQuery($sql);
		return $this->loadRow();
	}
	function xoa($ma)
	{
		$ma = intval($ma);

		$sql = "delete from phuong_thuc_thanh_toan where ma = '$ma'";
		$this->setQuery($sql);
		$this->query();
	}
	function them($ten_phuong_thuc, $mo_ta)
	{
		$ten_phuong_thuc = addslashes($ten_phuong_thuc);
		$mo_ta = addslashes($mo_ta);

		$sql = "INSERT INTO phuong_thuc_thanh_toan(ten_phuong_thuc,mo_ta) VALUES ('$ten_phuong_thuc','$mo_ta')";
		$this->setQuery($sql);
		return $this->query();
	}
	function cap_nhat($ma, $ten_phuong_thuc, $mo_ta)
	{
		$ma = intval($ma);
		$ten_phuong_thuc = addslashes($ten_phuong_thuc);
		$mo_ta = addslashes($mo_ta);

		$sql ="UPDATE phuong_thuc_thanh_toan SET ten_phuong_thuc= '$ten_phuong_thuc', mo_ta= '$mo_ta' WHERE ma = '$ma'";
		$this->setQuery($sql);
		return $this->query();
	}
	function tim_kiem ($tu_khoa)
	{
		$sql = "select * from phuong_thuc_thanh_toan where	$ten_phuong_thuc like %tu_khoa% or 	$mo_ta like %tu_khoa%"; 
		$this->setQuery($sql);
		return $this->loadAllRow();	
	}
 }
?>